package com.example.demo;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * java 模拟测试多线程测试http请求
 *
 * @author wdh
 */

public class ServiceThreadTest {

    public static void main(String[] args) {
        //运用java工具类中线程池
        ExecutorService pool = Executors.newCachedThreadPool();
//        for (int i = 0; i < 10; i++) { //开启俩个线程
//            String url = "https://hello.vecrp.com/";
//            Map<String, Object> paramStr = getHttpParamStr();
//            pool.execute(new ServiceThreadTest(url, paramStr));
//        }
    }

    public static Map<String, Object> getHttpParamStr() {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("apiversion", 1);
        param.put("appversion", "3.6.2");
        return param;
    }

    class RandomThread extends Thread {

        public RandomThread(String name) {
            super(name);
        }

        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}


